package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanhua.dubbo.mappers.UserPropertyMapper;
import com.tanhua.model.soul.UserProperty;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
@DubboService
public class UserPropertyApiImpl implements UserPropertyApi {
    @Autowired
    private UserPropertyMapper userPropertyMapper;
    @Override
    public Long save(UserProperty userProperty) {

         userPropertyMapper.insert(userProperty);
        LambdaQueryWrapper<UserProperty> qw=new LambdaQueryWrapper<>();
        qw.eq(UserProperty::getUserId,userProperty.getUserId());
        UserProperty userProperty1 = userPropertyMapper.selectOne(qw);
        return userProperty1.getId();
    }



    @Override
    public UserProperty findById(Long id) {

        return userPropertyMapper.selectById(id);
    }

    @Override
    public void update(UserProperty userProperty) {
        userPropertyMapper.updateById(userProperty);

    }

    @Override
    public UserProperty findByUserId(Long id) {
        LambdaQueryWrapper<UserProperty> qw=new LambdaQueryWrapper<>();
        qw.eq(UserProperty::getUserId,id);
        return userPropertyMapper.selectOne(qw);


    }
}
